<x:pager/>
<table id="studentTable" class="tablesorter">
    <thead>
        <tr>

            <th/>
            <th>${message(code: 'student.id.label', default: 'Family')}</th>
            <th>${message(code: 'student.firstName.label', default: 'First Name')}</th>
            <th>${message(code: 'student.lastName.label', default: 'Last Name')}</th>
            <th>${message(code: 'student.chineseName.label', default: 'Chinese Name')}</th>
            <th>${message(code: 'student.birthDay.label', default: 'Birth Date')}</th>
            <th>${message(code: 'student.gender.label', default: 'Gender')}</th>
            <g:if test="${session.roles?.contains('ROLE_ADMIN')}">
              <th class="delete">Del</th>
              <th class="edit">Edit</th>
              <th class="add">Class</th>
              <th class="add">Book</th>
            </g:if>

        </tr>
    </thead>
    <tbody>
    <g:each in="${instanceList}" status="i" var="studentInstance">
        <tr>

            <td>${i+1}</td>
            <td class="show"><a href="#" title="Student Detail" rel="${request.contextPath}/student/show/${studentInstance.id}">${fieldValue(bean: studentInstance, field: "family")}</a></td>
            <td>${fieldValue(bean: studentInstance, field: "firstName")}</td>
            <td>${fieldValue(bean: studentInstance, field: "lastName")}</td>
            <td>${fieldValue(bean: studentInstance, field: "chineseName")}</td>
            <td>${fieldValue(bean: studentInstance, field: "birthDay")}</td>
            <td>${fieldValue(bean: studentInstance, field: "gender")}</td>
            <g:if test="${session.roles?.contains('ROLE_ADMIN')}">
              <td class="delete"><g:remoteLink action="adminDelete" update="content" before="if(!confirm('Are you sure?')) return false;" id="${studentInstance.id}"><span class="ui-icon ui-icon-trash"/></g:remoteLink></td>
              <td class="edit"><a href="javascript:void(0)" title="Edit Student" rel="${request.contextPath}/student/adminCreate/${studentInstance.id}"><span class="ui-icon ui-icon-pencil"/></a></td>
              <td class="add"><a href="javascript:void(0)" title="Update Class" rel="${request.contextPath}/student/adminAddClass/${studentInstance.id}"><span class="ui-icon ui-icon-circle-plus"/></a></td>
              <td class="add"><a href="javascript:void(0)" title="Update Book" rel="${request.contextPath}/student/adminAddBook/${studentInstance.id}"><span class="ui-icon ui-icon-circle-plus"/></a></td>
            </g:if>

        </tr>
    </g:each>
    </tbody>
</table>

<script type="text/javascript">
    setupAdminList({controller:'student', action:'list', cluetipWidth:'600px', cluetipHeight:'500px'});
</script>